home *** CD-ROM | disk | FTP | other *** search
/ Champak 122 / Vol 122.iso / games / super_cr.swf / scripts / DefineSprite_380 / frame_168 / DoAction.as
Encoding:
Text File  |  2011-01-06  |  2.7 KB  |  117 lines

  1. stop();
  2. delete onEnterFrame;
  3. rdyButt.onRelease = function()
  4. {
  5.    play();
  6.    immobile = false;
  7.    lKey = 0;
  8.    rKey = 0;
  9.    playerSpeed = 10;
  10.    playerDistance = 0;
  11.    playerSpeedRnd = 0;
  12.    onEnterFrame = function()
  13.    {
  14.       pitchDistance += pitchSpeed / 144;
  15.       playerDistance += playerSpeed / 144;
  16.       pitchSpeed *= 0.9999;
  17.       pitchDistanceRnd = Math.round(pitchDistance) - Math.round(playerDistance);
  18.       if(pitchDistanceRnd <= 5)
  19.       {
  20.          gotoAndStop("end");
  21.          play();
  22.          delete onEnterFrame;
  23.       }
  24.       else if(pitchDistanceRnd <= 30)
  25.       {
  26.          ball._x = Stage.width - (30 - pitchDistanceRnd) * Stage.width / 60 - _X;
  27.       }
  28.       pitchSpeedRnd = Math.round(pitchSpeed);
  29.       if(pitchSpeedRnd <= 0)
  30.       {
  31.          gotoAndStop("fail");
  32.          play();
  33.          delete onEnterFrame;
  34.       }
  35.       playerSpeedRnd = Math.round(playerSpeed);
  36.       if(!immobile)
  37.       {
  38.          switch(rKey)
  39.          {
  40.             case 0:
  41.                if(Key.isDown(39))
  42.                {
  43.                   rKey = 1;
  44.                }
  45.                break;
  46.             case 1:
  47.                if(Key.isDown(39))
  48.                {
  49.                   rKey = 2;
  50.                }
  51.                else
  52.                {
  53.                   rKey = 0;
  54.                }
  55.                break;
  56.             case 2:
  57.                if(!Key.isDown(39))
  58.                {
  59.                   rKey = 0;
  60.                }
  61.          }
  62.          switch(lKey)
  63.          {
  64.             case 0:
  65.                if(Key.isDown(37))
  66.                {
  67.                   lKey = 1;
  68.                }
  69.                break;
  70.             case 1:
  71.                if(Key.isDown(37))
  72.                {
  73.                   lKey = 2;
  74.                }
  75.                else
  76.                {
  77.                   lKey = 0;
  78.                }
  79.                break;
  80.             case 2:
  81.                if(!Key.isDown(37))
  82.                {
  83.                   lKey = 0;
  84.                }
  85.          }
  86.          switch(runStage)
  87.          {
  88.             case 0:
  89.                if(rKey == 1)
  90.                {
  91.                   playerSpeed++;
  92.                   runStage = 1;
  93.                }
  94.                else if(lKey == 1)
  95.                {
  96.                   playerSpeed++;
  97.                   runStage = 2;
  98.                }
  99.                break;
  100.             case 1:
  101.                if(lKey == 1)
  102.                {
  103.                   playerSpeed++;
  104.                   runStage = 2;
  105.                }
  106.                break;
  107.             case 2:
  108.                if(rKey == 1)
  109.                {
  110.                   playerSpeed++;
  111.                   runStage = 1;
  112.                }
  113.          }
  114.       }
  115.    };
  116. };
  117.